<template>
  <div>
    <span>这是item的数据 {{$store.state.item.item}} {{item_num}}</span><button @click="con">添加item数据</button><br>
    <span>助手函数来实现</span><button @click="add_item(465)">添加</button><br>
    <span>{{change}}</span>
    <hr>
    <span>这是order的数据{{$store.state.order.item}}{{order_num}}</span><button @click="pu">添加order数据</button>
    <hr>
    <span>actions的方法</span><button @click="actions_gai">改</button>
  </div>
</template>
<script>
import { mapState, mapMutations, mapGetters } from 'vuex'
export default {
  methods: {
    con () {
      this.$store.commit('item/add_item', 20)
      console.log(this.$store)
    },
    pu () {
      this.$store.commit('order/add_item', '369')
    },
    ...mapMutations('item', ['add_item']),
    actions_gai () {
      // console.log(123)
      this.$store.dispatch('item/gai', '你好')
    }
  },
  computed: {
    ...mapState({
      item_num: state => {
        return state.item.item
      },
      order_num: state => {
        return state.order.item
      }
    }),
    ...mapGetters('item', ['change'])
  }
}
</script>
<style lang="scss" scoped>

</style>
